<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Component 标签</title>
    <script src="../assets/js/vue.js"></script>
</head>
<body>
    <h1>Component 标签</h1>
    <hr>
    <div id="app">
            <component v-bind:is="who"></component>
            <button @click="changeComponent">点击我切换标签</button>
    </div>
</body>
<script>
    var componentA = {
        template:`<div>我是componentA</div>`
    }
    var componentB = {
        template:`<div>我是componentB</div>`
    }
    var componentC = {
        template:`<div>我是componentC</div>`
    }
    var app = new Vue({
        el:"#app",
        data:{ 
            who:'componentA'
        },
        components:{
            "componentA":componentA,
            "componentB":componentB,
            "componentC":componentC,
        },
        methods:{
            changeComponent(){
                if(this.who=="componentA"){
                    this.who = "componentB"
                }else if(this.who == "componentB"){
                    this.who = "componentC"
                }else{
                    this.who = "componentA"
                }
            }
        }
        
    })
</script>
</html>